<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div data-id = "1" data-spm = "不知道">1</div>
  <script>
    //获取元素
    const div = document.querySelector(`div`)
    //通过dataset获取自定义属性
    console.log(div.dataset) //DOMStringMap对象,里面存储自定义对象
    console.log(div.dataset.id) //1
  </script>
</body>
</html>